<?php
    function print_maps_pages(){
    	
		
		global $version, $theme_data_content, $theme_popup, $theme_data, $theme_overlay, $config_xml, $iconPath;
		$pageNum = -1;
		$bg_img_path = "images/maps/background/";
		$button_img_path = "images/maps/button/";

		if (file_exists("maps.xml")) {
			$maps_xml = simplexml_load_file("maps.xml");
		} else {
			echo "Konnte maps.xml Datei nicht laden. ";
			return;
		}
	
	
		//	Kategorien einlesen und sortieren
		$path = "/Maps/Map";
		if (!$maps = $maps_xml -> xpath($path)) {
			echo "keine Karten vorhanden!";
		} else {
			
			foreach ($maps as $map) {
				
				if($pageNum != -1) {
					
					print_footer_light('maps', $pageNum, FALSE);
					print_page_end();
				}
				
				
				////7 Seite pro MAp
				
				
				$pageNum += 1;
				$pageTitle = $map->Name;
				print_page_start('maps', $pageNum);
				print_menu_popup($pageNum);
				print_single_actor_popup($pageNum);
				print_header_light((string)$pageTitle);
				print_page_header($theme_data);
				
				$imgpath = $map->BG_IMG;
				$imgpath = $bg_img_path . $imgpath;
				
// Hintergrundbild setzen					
				echo "
			
				<div style=\"position:absolute; width:95%; left:0px; border:solid 0px blue; padding:5px; max-height:80%\" >
					<div id=picture  >
						<img src=$imgpath width=100% alt=$pageTitle>
					</div>";
			//	var_dump($map);	
				foreach($map->Button as $button) {
					$buttonpath = $button_img_path . $button->IMG;
					$width = $button->width;
					$height = $button->height;
					$top = $button->top;
					$left = $button->left;
					$actor = $button->actor;
					$action = $button->action;
					$name = $button->name;
					$perform_on_click = "";
					$level = 0;
					
					// Funktion für den Button aktivieren
					// Wenn direkte Funktion mit gegeben, dann wird auch diese ausgeführt
					if ($action == '') {
						$perform_on_click = 'showActorPopup(\'' . $actor . '\', ' . $pageNum . ')';
						
					} else {
						 if (is_numeric((string)$action)) {
						 	$level = (int)$action;
							$action = 'DIM';
						 }

						$perform_on_click = 'perform_light_change(\'' . $actor .'\', \'' . $action . '\', \'' . $level . '\') ';
											
					}
					
					
					
echo "					
					<div  style=\"position:absolute; top:$top%; left:$left%; width:$width%; height:$height%; z-index=3; border:solid 0px blue;\">
						<a href='#'>
							<div style=\"position:absolute; top:0px; left:0px; z-index=4; border:solid 0px blue;\" onclick=\"$perform_on_click;\">
								<img src=$buttonpath width=100% alt=$name>
							</div>
						</a>	
					</div>	";					
				}
				
				echo"
				</div>
			</div>";
			}
		}
		
		print_footer_light('maps', $pageNum, TRUE);
		print_page_end();
    }



?>